package com.bonc.event.extractor;

/**
 * @author donggui@bonc.com.cn
 * @version 2016 2016年6月28日 下午2:59:42
 */
public class Trigger {
	private String literal;

	/**
	 * The {@link LexicalCategory} that the piece of text must have
	 */
	private String lexicalCategory;

	public Trigger(String literal, String lexicalCategory) {
		if (literal == null || literal.equals("")) {
			throw new IllegalArgumentException("text must not be null or empty");
		}

		if (lexicalCategory == null) {
			throw new IllegalArgumentException("lexicalCategory must not be null");
		}

		this.literal = literal;
		this.lexicalCategory = lexicalCategory;
	}

	public String getLiteral() {
		return literal;
	}

	public String getLexicalCategory() {
		return lexicalCategory;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + literal.hashCode();
		result = prime * result + lexicalCategory.hashCode();

		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;

		Trigger other = (Trigger) obj;

		return literal.equals(other.literal) && lexicalCategory.equals(other.lexicalCategory);
}
}
